<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/6/25
 * Time: 15:17
 */

namespace app\admin\controller;


use app\admin\logic\CivilizationCateLogic;
use app\admin\logic\CivilizationLogic;
use think\facade\Request;

class Civilization extends Base
{

    private $CivilizationLogic;

    public function __construct()
    {
        parent::__construct();
        $this->CivilizationLogic = new CivilizationLogic();
    }

    public function index(){
        return $this->fetch();
    }

    public function ajaxIndex(){
        $where = Request::param();
        $res = $this->CivilizationLogic->CivilizationList($where, self::$nowPage);
        return json($res);
    }

    public function add(){
        $id = Request::get('id');
        $act = 'add';
        if ($id){
            $act = 'edit';
            $cateInfo = $this->CivilizationLogic->info($id);
            $this->assign('info', $cateInfo['data']);
        }
        $cateLogic = new CivilizationCateLogic();
        $cateList = $cateLogic->getAllCate();
        $this->assign('cate_list', $cateList['data']);
        $this->assign('act', $act);
        return $this->fetch();
    }

    public function handle(){
        $data = Request::param();
        $res = $this->CivilizationLogic->handle($data);
        return json($res);
    }


}